package codetop.microsoft.T238;

/**
 * @Author: 18362
 * @Create: 2022-08-16 13:48:15 星期二
 */
class Solution {
    public int[] productExceptSelf(int[] nums) {
        int[] ans = new int[nums.length];
        ans[0] = 1;
        for (int i=1; i<nums.length; ++i)
            ans[i] = ans[i-1] * nums[i-1];
        int post = 1;
        for (int i=nums.length-1; i>=0; --i) {
            ans[i] = post * ans[i];
            post *= nums[i];
        }
        return ans;
    }
}